package com.dog.basics.admin.controller.common;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.sys.SysFileInfoFromDto;
import com.dog.basics.bean.vo.admin.sys.SysFileInfoVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.common.IDogSysFileInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/admin/file")
@Api(value = SwaggerConstants.SYSTEM+"文件管理", tags = SwaggerConstants.SYSTEM+"文件管理")
@AllArgsConstructor
@ApiIgnore
public class DogSysFileInfoController {
    private final IDogSysFileInfoService dogSysFileInfoService;

    /**
     * @Description: 文件分页列表
     * @Param: name
     * @return: IPage<SysFileInfoVo>
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @ApiOperation(value = "文件分页列表", notes = "pc:file:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:file:page')")
    public R<IPage<SysFileInfoVo>> getFilePageList(PageParam param, SysFileInfoFromDto sysFileInfoFromDto) {
        return R.ok(dogSysFileInfoService.getFilePageList(param, sysFileInfoFromDto));
    }

    /**
     * @Description: 删除文件
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/4/27  0027
     */
    @SysLog("删除文件")
    @ApiOperation(value = "删除文件", notes = "pc:file:delete")
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:game:delete')")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(dogSysFileInfoService.deleteObj(id));
    }

}
